#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+9;
int v[maxn];
int main() {
  int n;cin>>n;
  for(int i=1;i<=n;++i)cin>>v[i];
  if(n==1||is_sorted(v+1, v+n+1)){cout<<"1 1\n";return 0;}
  int i,j;
  for(i=1;i<=n;++i) {
    if(v[i]>v[i+1])break;
  }
  for(;i>1;--i) {
    if(v[i-1]!=v[i])break;
  }
  for(j=n;j>0;--j) {
    if(v[j]<v[j-1])break;
  }
  for(;j<n;++j) {
    if(v[j+1]!=v[j])break;
  }
  reverse(v+i, v+j+1);
  if(is_sorted(v+1, v+n+1))cout<<i<<' '<<j<<'\n';
  else cout<<"impossible\n";
}
